package com.sali.b_design_pattern.g_singleton_pattern.lesson_singleton.a_hungry;

/**
 * @description:
 * @date: 2023/3/19 12:41.
 * @version: 1.0
 */
public class B_HungryStaticSingleton {

    private static B_HungryStaticSingleton instance;

    /**
     * description: 静态初始化（类调静态方法时才会执行此静态代码块，它只会执行一次，从而解决饿汉单例浪费内存空间的问题）
     **/
    static {
        instance = new B_HungryStaticSingleton();
    }


    /**
     * description: 构造函数私有化
     **/
    private B_HungryStaticSingleton() {
    }

    /**
     * description: 返回单例对象
     **/
    public static B_HungryStaticSingleton getInstance() {
        return instance;
    }

}
